<?php
namespace app\web\controller;

use think\Db;
use think\Request;
use app\common\controller\commonApi as comm;

/**
 * Class Log
 * @package app\web\controller
 * by J.sky
 * 2020年5月5日
 */
class Log
{
    /**
     * 日志列表
     * by J.sky
     * 2020年5月5日
     */
    public function logList(Request $request)
    {
        try {
            //获取管理员信息
            $adminInfo = $request->adminInfo;
            $limit = input('post.limit',15,'trim');
            $listObj = Db::name("log")->order('time', 'desc')->paginate($limit);
            return ret(200, '成功', ["data"=>$listObj->toArray()['data'],"total"=>$listObj->toArray()['total']]);
        } catch (\Exception $e) {
            comm::oplog("sql错误", $adminInfo['id'], $adminInfo['username'], json_encode(['错误API' => retMAC(), 'error' => $e->getMessage(), '操作用户IP' => get_ip()]));
            rLog(['operate' => 'sql错误', 'error' => $e->getMessage()]);
            ret(404, '服务器异常请联系管理员');
        }
    }
}
